package com.zky.controller;

import com.zky.domain.ResponseResult;
import com.zky.domain.dto.UserAddDto;
import com.zky.domain.dto.UserListDto;
import com.zky.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/system/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/list")
    public ResponseResult getAllUserList(Integer pageNum, Integer pageSize, UserListDto userListDto) {
        return userService.getAllUserList(pageNum, pageSize, userListDto);
    }

    @PostMapping
    public ResponseResult addUser(@RequestBody UserAddDto userAddDto){
        return userService.addUser(userAddDto);
    }

    @DeleteMapping("/{id}")
    public ResponseResult deleteUser(@PathVariable Long id){
        return userService.deleteUser(id);
    }

    @GetMapping("/{id}")
    public ResponseResult getUserInfoById(@PathVariable Long id){
        return userService.getUserInfoById(id);
    }

    @PutMapping
    public ResponseResult updateUser(@RequestBody UserAddDto userAddDto){
        return userService.updateUser(userAddDto);
    }
}
